from pathlib import Path
from PIL import Image
import os
for img in Path(".").parent.absolute().joinpath('wbh').iterdir():
    img_path = img.absolute()
    name, parent = img_path.name, img_path.parent
    if img_path.suffix not in ['.jpg', '.png', '.json']:
        try:
            img = Image.open(img_path.as_posix())
            os.remove(img_path.as_posix())
            img.save(parent.joinpath(name+'.png').as_posix())
            print(img_path)
        except:
            print(img_path,'is invalid')